﻿namespace Harness.Recording.LocateParsers
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using mshtml;

    internal class InputButtonLocateParseBehavior : LocateParser.ILocateParseBehavior
    {
        public string Parse(IHTMLElement element)
        {
            IHTMLInputElement input = element as IHTMLInputElement;

            if (null == input)
            {
                return string.Empty;
            }

            string type = input.type.ToLower();
            
            if ("button" != type
                && "submit" != type
                && "reset" != type)
            {
                return string.Empty;
            }

            string s = input.value;

            if (string.IsNullOrWhiteSpace(s))
            {
                return string.Empty;
            }

            return string.Format("button={0}", s);
        }
    }
}
